package com.communal.web;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.communal.service.IApplicationService;
import com.communal.util.AppException;

/**
 * Handles common request for application <br>
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
@Controller
public class ApplicationController extends AbstractController{

	private final String LOAD_APP_VERSION_ACTION = "/application/info.action";
	
	@Autowired
	IApplicationService applicationService;
	
	/**
	 * Handles request for load information about application
	 * @return @ResponseBody Map<String, ? extends Object>
	 */
	@RequestMapping(value=LOAD_APP_VERSION_ACTION)
	public @ResponseBody Map<String, ? extends Object> getApplicationInfo() {
		try{
			String vesrionData = applicationService.getApplicationAboutData(); 
			return getMap(vesrionData);
		} catch (AppException error) {
			return getModelMapError(error.getMessage());
		}
	}

	
	
}
